package com.ad.pet.api;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.ad.pet.App;
import com.ad.pet.common.data.utils.JsonUtil;
import com.ad.pet.common.data.utils.SpUtil;
import com.ad.pet.common.structure.key.TokenKey;
import com.ad.pet.constant.Constant;
import com.ad.pet.models.remote.CommList;
import com.ad.pet.models.remote.KeyWord;
import com.ad.pet.models.remote.Money;
import com.ad.pet.models.remote.PayResult;
import com.ad.pet.models.remote.Upgrade;
import com.ad.pet.models.remote.User;
import com.ad.pet.models.remote.account.AboutUs;
import com.ad.pet.models.remote.account.Account;
import com.ad.pet.models.remote.account.AccountPet;
import com.ad.pet.models.remote.account.Banlance;
import com.ad.pet.models.remote.account.CountDrawTotal;
import com.ad.pet.models.remote.account.UserBuyReturn;
import com.ad.pet.models.remote.account.YueDetail;
import com.ad.pet.models.remote.account.order.BigOrder;
import com.ad.pet.models.remote.account.order.OrderDetail;
import com.ad.pet.models.remote.account.order.OrderType;
import com.ad.pet.models.remote.account.order.PayCompleted;
import com.ad.pet.models.remote.account.order.PayMethodAll;
import com.ad.pet.models.remote.account.order.PayUrl;
import com.ad.pet.models.remote.account.order.SignCheck;
import com.ad.pet.models.remote.account.pet.PetCateFirst;
import com.ad.pet.models.remote.account.pet.PetColor;
import com.ad.pet.models.remote.account.share.ShareEndItem;
import com.ad.pet.models.remote.address.Address;
import com.ad.pet.models.remote.address.Province;
import com.ad.pet.models.remote.cart.BigShipingw;
import com.ad.pet.models.remote.cart.Continent;
import com.ad.pet.models.remote.cart.Coupons;
import com.ad.pet.models.remote.cart.EditNum;
import com.ad.pet.models.remote.cart.Good;
import com.ad.pet.models.remote.cart.HistoryCountry;
import com.ad.pet.models.remote.cart.NewProduct;
import com.ad.pet.models.remote.collect.BigArticle;
import com.ad.pet.models.remote.collect.CollectShop;
import com.ad.pet.models.remote.home.BigAdver;
import com.ad.pet.models.remote.home.Cate;
import com.ad.pet.models.remote.home.Home;
import com.ad.pet.models.remote.home.HomeMall;
import com.ad.pet.models.remote.home.HomeProduce;
import com.ad.pet.models.remote.home.NewUserBenfit;
import com.ad.pet.models.remote.home.Notice;
import com.ad.pet.models.remote.home.Product_list;
import com.ad.pet.models.remote.home.VpPacket;
import com.ad.pet.models.remote.home.Zoom;
import com.ad.pet.models.remote.home.floor.MainFloor;
import com.ad.pet.models.remote.home.floor.PopNewRegist;
import com.ad.pet.models.remote.login.CategroyCountry;
import com.ad.pet.models.remote.main.DesingerMain;
import com.ad.pet.models.remote.main.DesingerType;
import com.ad.pet.models.remote.main.PetConcer;
import com.ad.pet.models.remote.mall.Counpous;
import com.ad.pet.models.remote.mall.OrderDoorInfo;
import com.ad.pet.models.remote.mall.ProductDetail;
import com.ad.pet.models.remote.mall.Rating;
import com.ad.pet.models.remote.mall.Record;
import com.ad.pet.models.remote.mall.SearchEndGood;
import com.ad.pet.models.remote.mall.ServiceDetail;
import com.ad.pet.models.remote.mall.SkuPirce;
import com.ad.pet.models.remote.message.LogistDetail;
import com.ad.pet.models.remote.message.Message;
import com.ad.pet.models.remote.message.Point;
import com.ad.pet.models.remote.recharge.Alipay;
import com.ad.pet.models.remote.recharge.Recharge;
import com.ad.pet.models.remote.recharge.Weixin;
import com.ad.pet.models.remote.recharge.WithDraw;
import com.ad.pet.models.remote.type.FirstCategroy;
import com.ad.pet.models.remote.zoom.StyleList;
import com.ad.pet.models.remote.zoom.ZoomList;
import com.ad.pet.models.result.ResultBean;
import com.ad.pet.utils.LyxUtils;

import java.io.File;
import java.util.HashMap;
import java.util.List;

import cn.jpush.android.api.JPushInterface;
import retrofit2.Retrofit;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Created by ems on 2017/2/27.
 */

public class ApiService {

    Retrofit retrofit;
    JsonUtil mJsonUtil;
    private final Api api;

    public ApiService(Retrofit retrofit, JsonUtil jsonUtil) {
        this.retrofit = retrofit;
        this.mJsonUtil = jsonUtil;
        api = retrofit.create(Api.class);
    }

    //获取基本的参数
    String android = "android";

    @NonNull
    public HashMap<String, String> getMap() {
        HashMap<String, String> map = new HashMap<>();
//        map.put("version", SystemUitl.getVersionName(App.getApp()));
        map.put(Constant.PLATFORM, "android");
        map.put(Constant.DEVICE_ID, LyxUtils.getIMEI(App.getApp()));
        map.put(Constant.LANG, SpUtil.getInstance().getString(Constant.LANGUAGE, "cn"));
        map.put(Constant.CURRENCY, SpUtil.getInstance().getString(Constant.CURRENCY_ABBR, "USD"));
        map.put(Constant.CHOSE_COUNTRY, SpUtil.getInstance().getString(Constant.CHOSE_COUNTRY));
        return map;
    }


//    /**
//     * 登录
//     */
//    public Observable<ResultBean<User>> login(String naid, String phone, String psd) {
//        Map<String, Object> map = getMap();
//        map.put("na_id", naid);
//        map.put("mobile", phone);
//        map.put("password", psd);
//        String json = JsonUtil.getInstance().toJson(map);
//        return api.login(json)
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread());
//    }


    /**
     * 校验手机号码是否已经登陆
     */
    public Observable<User> checkMobile(String phone) {
        return api.getDemo("user.index/check_mobiel_is_register",phone) .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
            @Override
            public Observable<User> call(ResultBean<User> bean) {
                return ResultCheck.checkResponse(bean);
            }
        })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 获取国家列表
     */
    public Observable<List<CategroyCountry>> getCountrys(String longitude, String latitude) {

        return api.get_country_list("home.index/get_city_list", longitude, latitude)
                .flatMap(new Func1<ResultBean<List<CategroyCountry>>, Observable<List<CategroyCountry>>>() {
                    @Override
                    public Observable<List<CategroyCountry>> call(ResultBean<List<CategroyCountry>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 第三方登录
     */
    public Observable<ResultBean<User>> check_bind_third(String uid) {
        return api.check_bind("user.index/is_bind_mobile", uid, JPushInterface.getRegistrationID(App.getApp()).toString(),android)
                .observeOn(AndroidSchedulers.mainThread());


    }

    /**
     * 发邮件验证码
     *
     * @param email
     * @return
     */
    public Observable<User> send_email_code(String email) {
        HashMap<String, String> map = getMap();
        map.put(Constant.E_MAIL, email);
        return api.send_email_code(map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), email, LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 邮箱注册
     */
    public Observable<User> register(String email, String pwd, String gender, String thirdPart, String sex) {
        HashMap<String, String> map = getMap();
        map.put(Constant.E_MAIL, email);
        map.put(Constant.USER_PASSWORD, pwd);
        map.put(Constant.SHARE_CODE, gender);
        map.put(Constant.THIRD_PARTY, thirdPart);
        map.put(Constant.GENDER, sex);

        return api.register(map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.E_MAIL), map.get(Constant.USER_PASSWORD), map.get(Constant.SHARE_CODE)
                , thirdPart, sex, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                });
    }

    /**
     * 账号登录
     */
//    public Observable<User> accountLogin(String account,
//                                         String password) {
//        HashMap<String, String> map = getMap();
//        map.put(Constant.USER_TEL, account);
//        map.put(Constant.USER_PASSWORD, password);
//        return api.phone_login(account,password)
//                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
//                    @Override
//                    public Observable<User> call(ResultBean<User> bean) {
//                        return ResultCheck.checkResponse(bean);
//                    }
//                })
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread());
//    }


    /**
     * 校验token
     */
    public Observable<ResultBean<User>> checkToken(String accountToken
    ) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ACCESS_TOKEN, accountToken);
        return api.check_login(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), accountToken, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 商城
     */
    public Observable<Product_list> getHome(String page) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PAGE, page);
        map.put(Constant.LIMIT, "50");
        return api.getHome(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), page, "50", LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Product_list>, Observable<Product_list>>() {
                    @Override
                    public Observable<Product_list> call(ResultBean<Product_list> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 首页
     */
    public Observable<CommList<HomeProduce>> getHome_index() {
        HashMap<String, String> map = getMap();
        return api.getHome_index(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<HomeProduce>>, Observable<CommList<HomeProduce>>>() {
                    @Override
                    public Observable<CommList<HomeProduce>> call(ResultBean<CommList<HomeProduce>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 通知
     */
    public Observable<List<Notice>> getNoticeList() {
        HashMap<String, String> map = getMap();
        return api.get_notice_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<Notice>>, Observable<List<Notice>>>() {
                    @Override
                    public Observable<List<Notice>> call(ResultBean<List<Notice>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 轮播图
     */
    public Observable<Home> getPicList(String type, String longtitu, String latitude) {
        return api.get_pic_list("home.index/get_home_info", type, longtitu, latitude)
                .flatMap(new Func1<ResultBean<Home>, Observable<Home>>() {
                    @Override
                    public Observable<Home> call(ResultBean<Home> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 分类
     */
    public Observable<CommList<List<Cate>>> top_bar() {
        HashMap<String, String> map = getMap();
        return api.top_bar(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Cate>>>, Observable<CommList<List<Cate>>>>() {
                    @Override
                    public Observable<CommList<List<Cate>>> call(ResultBean<CommList<List<Cate>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 分类
     */
    public Observable<CommList<List<Cate>>> top_bar_menu() {
        HashMap<String, String> map = getMap();
        return api.top_bar_menu(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Cate>>>, Observable<CommList<List<Cate>>>>() {
                    @Override
                    public Observable<CommList<List<Cate>>> call(ResultBean<CommList<List<Cate>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 获取挂念次
     */
    public Observable<List<KeyWord>> getHotKeyword() {
        HashMap<String, String> map = getMap();
        return api.recommend_word(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<KeyWord>>, Observable<List<KeyWord>>>() {
                    @Override
                    public Observable<List<KeyWord>> call(ResultBean<List<KeyWord>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<CommList<List<KeyWord>>> main_search_words() {
        HashMap<String, String> map = getMap();
        return api.main_search_words(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<KeyWord>>>, Observable<CommList<List<KeyWord>>>>() {
                    @Override
                    public Observable<CommList<List<KeyWord>>> call(ResultBean<CommList<List<KeyWord>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<CommList<List<KeyWord>>> getcategorylist() {
        HashMap<String, String> map = getMap();
        return api.getcategorylist(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<KeyWord>>>, Observable<CommList<List<KeyWord>>>>() {
                    @Override
                    public Observable<CommList<List<KeyWord>>> call(ResultBean<CommList<List<KeyWord>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 用户注销
     */
    public Observable<User> loginOut(String text) {
        return api.logout("user.index/loginout",text)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 用户升级
     */
    public Observable<Upgrade> upGrade(String versionCode) {
        HashMap<String, String> map = getMap();
        map.put(Constant.VERSION_NUMBER, versionCode);
        return api.upGrade(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.put(Constant.VERSION_NUMBER, versionCode), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Upgrade>, Observable<Upgrade>>() {
                    @Override
                    public Observable<Upgrade> call(ResultBean<Upgrade> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * zoom
     */
    public Observable<List<Zoom>> getZoom() {
        HashMap<String, String> map = getMap();
        return api.get_category_info(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<Zoom>>, Observable<List<Zoom>>>() {
                    @Override
                    public Observable<List<Zoom>> call(ResultBean<List<Zoom>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 购物车
     */
    public Observable<CommList<List<Good>>> cart_lists() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.cart_lists(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Good>>>, Observable<CommList<List<Good>>>>() {
                    @Override
                    public Observable<CommList<List<Good>>> call(ResultBean<CommList<List<Good>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 上传支付日志
     */
    public Observable<PayResult> write_notify_log(
                                                  String oid,String type) {

        return (TextUtils.isEmpty(type)?api.write_notify_log("order.pay/index",oid):api.write_notify_log("order.pay/index",oid,type))
                .flatMap(new Func1<ResultBean<PayResult>, Observable<PayResult>>() {
                    @Override
                    public Observable<PayResult> call(ResultBean<PayResult> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    /**
     * 上传支付日志
     */
    public Observable<OrderDoorInfo> getDoorBasicInfo(String date,String shop_id) {

        return api.getDoorBasicInfo("shop.index/shop_basic_info", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),date,shop_id)
                .flatMap(new Func1<ResultBean<OrderDoorInfo>, Observable<OrderDoorInfo>>() {
                    @Override
                    public Observable<OrderDoorInfo> call(ResultBean<OrderDoorInfo> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    /**
     * 上传支付日志
     */
    public Observable<List> upDoorOrder(String contact_name,String contact_tel,String shop_id,String pet_id,String offservice_id,String offservice_name,String offservice_sku_id,String offservice_sku_name,String appoint_offservice_date,String appoint_offservice_time,String voucher_id,String price) {

        return api.upDoorOrder("shop.index/shop_appointment",SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), contact_name, contact_tel, shop_id, pet_id, offservice_id, offservice_name, offservice_sku_id, offservice_sku_name, appoint_offservice_date, appoint_offservice_time, voucher_id, price,"")
                .flatMap(new Func1<ResultBean<List>, Observable<List>>() {
                    @Override
                    public Observable<List> call(ResultBean<List> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 删除购物车货物
     */
    public Observable<User> del_item(
            String cIds) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        map.put(Constant.CART_IDS, cIds);
        return api.del_item(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), cIds, map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 修改数量
     */
    public Observable<EditNum> edit_item(String cId,
                                         String num, String sku) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        map.put(Constant.CART_ID, cId);
        map.put(Constant.QUANTITY, num);
        map.put(Constant.SKU, sku);
        return api.edit_item(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), cId, num, sku, map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<EditNum>, Observable<EditNum>>() {
                    @Override
                    public Observable<EditNum> call(ResultBean<EditNum> editNumResultBean) {
                        return ResultCheck.checkResponse(editNumResultBean);
                    }
                }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 获取商品总价
     */
    public Observable<EditNum> getCartPrice(String cId) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        map.put(Constant.CART_IDS, cId);

        return api.getCartPrice(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), cId, map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<EditNum>, Observable<EditNum>>() {
                    @Override
                    public Observable<EditNum> call(ResultBean<EditNum> editNumResultBean) {
                        return ResultCheck.checkResponse(editNumResultBean);
                    }
                }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 确认订单
     */
    public Observable<PayCompleted> confirm(String cIds, String aid, String sid, String balance, String red_envelope, String freight, String counposId) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        map.put(Constant.CART_IDS, cIds);
        map.put(Constant.ADDRESS_ID, aid);
        map.put(Constant.SHIPPING_ID, sid);
        map.put(Constant.BANLANCE, balance);
        map.put(Constant.RED_ENVELOPS, red_envelope);
        map.put(Constant.FREIGHT, freight);
        map.put(Constant.USER_COUPON_ID, counposId);
        return api.confirmOrder(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), cIds, aid, sid, balance, red_envelope, freight, map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), counposId, LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<PayCompleted>, Observable<PayCompleted>>() {
                    @Override
                    public Observable<PayCompleted> call(ResultBean<PayCompleted> payCompletedResultBean) {
                        return ResultCheck.checkResponse(payCompletedResultBean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 优惠券
     */
    public Observable<CommList<List<Counpous>>> getCouponList(String state, String offid, String week_numBODY
    ) {

//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.getCouponList("discounts.index/my_service_coupon_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),offid,week_numBODY)
                .flatMap(new Func1<ResultBean<CommList<List<Counpous>>>, Observable<CommList<List<Counpous>>>>() {
                    @Override
                    public Observable<CommList<List<Counpous>>> call(ResultBean<CommList<List<Counpous>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 确认订单选择国家地区列表
     */
    public Observable<List<Continent>> getCountryList() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.getCountryList(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<Continent>>, Observable<List<Continent>>>() {
                    @Override
                    public Observable<List<Continent>> call(ResultBean<List<Continent>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 确认订单选择国家地区列表
     */
    public Observable<List<HistoryCountry>> getHistoryCountryList(
    ) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.getHistoryCountryList(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<HistoryCountry>>, Observable<List<HistoryCountry>>>() {
                    @Override
                    public Observable<List<HistoryCountry>> call(ResultBean<List<HistoryCountry>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 添加国家地址
     */
    public Observable<HistoryCountry> addAdress(String cId, String cName
    ) {
        HashMap<String, String> map = getMap();
        map.put(Constant.COUNTRY_NAME, cName);
        map.put(Constant.COUNTRY_ID, cId);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.addAddress(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), cId, cName, map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<HistoryCountry>, Observable<HistoryCountry>>() {
                    @Override
                    public Observable<HistoryCountry> call(ResultBean<HistoryCountry> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 弹窗
     */
    public Observable<Home> getUserLandingPageReg(
    ) {
        return api.getUserLandingPageReg("home.index/get_home_adv","3")
                .flatMap(new Func1<ResultBean<Home>, Observable<Home>>() {
                    @Override
                    public Observable<Home> call(ResultBean<Home> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 支付列表
     */
    public Observable<CommList<List<Recharge>>> get_channel_list(
    ) {
        HashMap<String, String> map = getMap();
        return api.channel_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Recharge>>>, Observable<CommList<List<Recharge>>>>() {
                    @Override
                    public Observable<CommList<List<Recharge>>> call(ResultBean<CommList<List<Recharge>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 微信支付
     */
    public Observable<Weixin> get_pay_wx(String value, String type
    ) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PAY_VALUE, value);
        map.put(Constant.PAYTYPE, type);
        return api.get_pay_wx(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.PAY_VALUE), map.get(Constant.PAYTYPE), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Weixin>, Observable<Weixin>>() {
                    @Override
                    public Observable<Weixin> call(ResultBean<Weixin> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 支付宝支付
     */
    public Observable<Alipay> get_pay_alipay(String value, String type
    ) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PAY_VALUE, value);
        map.put(Constant.PAYTYPE, type);
        return api.get_pay_alipay(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.PAY_VALUE), map.get(Constant.PAYTYPE), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Alipay>, Observable<Alipay>>() {
                    @Override
                    public Observable<Alipay> call(ResultBean<Alipay> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<AccountPet> getPetInfo(String petId) {

        return api.getPetInfo("user.pet/petdetail", petId)
                .flatMap(new Func1<ResultBean<AccountPet>, Observable<AccountPet>>() {
                    @Override
                    public Observable<AccountPet> call(ResultBean<AccountPet> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<PetCateFirst>> getPetCate() {

        return api.getPetCateGory("user.pet/petcategory")
                .flatMap(new Func1<ResultBean<List<PetCateFirst>>, Observable<List<PetCateFirst>>>() {
                    @Override
                    public Observable<List<PetCateFirst>> call(ResultBean<List<PetCateFirst>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> deletePet(String petId) {

        return api.deletePet("user.pet/delpet", petId)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<PetColor>> getPetColor() {

        return api.getPetColor("user.pet/petcolor")
                .flatMap(new Func1<ResultBean<List<PetColor>>, Observable<List<PetColor>>>() {
                    @Override
                    public Observable<List<PetColor>> call(ResultBean<List<PetColor>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List> upPetInfo(String pet_headimg, String pet_name, String sex, String birthday, String category_id, String weight, String is_sterilisate, String color_id, String pet_id) {

        return api.upPetInfo("user.pet/addupdatepet", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), pet_headimg, pet_name, sex, birthday, category_id, weight, is_sterilisate, color_id, pet_id)
                .flatMap(new Func1<ResultBean<List>, Observable<List>>() {
                    @Override
                    public Observable<List> call(ResultBean<List> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<Account> get_user_info() {
        return api.get_user_info("user.index/get_personal_center_info", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN))
                .flatMap(new Func1<ResultBean<Account>, Observable<Account>>() {
                    @Override
                    public Observable<Account> call(ResultBean<Account> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List> upUserinfo(String user_headimg, String user_name, String nick_name, String sex, String birthday, String user_tel) {
        return api.up_user_info("user.index/updateuserinfo", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), user_headimg, user_name, nick_name, sex, birthday, user_tel)
                .flatMap(new Func1<ResultBean<List>, Observable<List>>() {
                    @Override
                    public Observable<List> call(ResultBean<List> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 上传头像
     *
     * @param file
     * @return
     */
    public Observable<ResultBean<String>> upload_avatar(File file, String type
    ) {
//        MultipartBody.Part photoPart = null;
//
//        if (file != null) {
//            RequestBody bodyPhoto = RequestBody.create(MediaType.parse("image/png"), file);
//            photoPart = MultipartBody.Part.createFormData("file",System.currentTimeMillis()+".jpg", bodyPhoto);
//        }
//
//        RequestBody method = RequestBody.create(null, "upload.oss/upload");
//        RequestBody typea = RequestBody.create(null, type);

        return api.upload_avatar("upload.oss/upload_base", LyxUtils.imageToBase64(file), type)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 重置密码
     *
     * @param email
     * @return
     */
    public Observable<User> forget_pwd(String email, String code, String pwd) {
        HashMap<String, String> map = getMap();
        map.put(Constant.METHOD, "user.index/forgot_password");
        map.put(Constant.SMS_CODE, code);
        map.put(Constant.USER_PASSWORD, pwd);
        map.put(Constant.USER_TEL, email);
        return api.forgot_password(map.get(Constant.METHOD), email, code, pwd)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> reggistJpush() {
        HashMap<String, String> map = getMap();
        map.put(Constant.METHOD, "user.index/edit_jiguang_info");


        return api.registJpush(map.get(Constant.METHOD), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), JPushInterface.getRegistrationID(App.getApp()).toString(), android)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 地址列表
     *
     * @return
     */
    public Observable<List<Address>> address_list() {

        return api.address_list("user.address/get_address_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), "1", "100")
                .flatMap(new Func1<ResultBean<List<Address>>, Observable<List<Address>>>() {
                    @Override
                    public Observable<List<Address>> call(ResultBean<List<Address>> commListResultBean) {
                        return ResultCheck.checkResponse(commListResultBean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 地址更新
     *
     * @return
     */
    public Observable<User> address_update(String address_id, String consigner, String mobile,
                                           String province, String city, String district, String address, String label,
                                           int defaults) {


        return api.address_update("user.address/save_address", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), address_id, consigner, mobile,
                province, city, district, address, label,
                defaults + "")
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 地址添加
     *
     * @return
     */
    public Observable<User> address_add(String consigner, String mobile,
                                        String province, String city, String district, String address, String label,
                                        int defaults) {


        return api.address_add("user.address/add_address", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), consigner, mobile,
                province, city, district, address, label,
                defaults + "")
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<ServiceDetail> get_service_detail(String oid, String sid) {
        return api.service_detail("shop.index/offservice_detail", SpUtil.getInstance().getString(TokenKey.TOKEN), oid, sid)
                .flatMap(new Func1<ResultBean<ServiceDetail>, Observable<ServiceDetail>>() {
                    @Override
                    public Observable<ServiceDetail> call(ResultBean<ServiceDetail> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<SkuPirce> get_sku_price(String oid, String attr_str) {
        return api.get_sku_price("shop.index/getoffservice_sku", SpUtil.getInstance().getString(TokenKey.TOKEN), oid, attr_str)
                .flatMap(new Func1<ResultBean<SkuPirce>, Observable<SkuPirce>>() {
                    @Override
                    public Observable<SkuPirce> call(ResultBean<SkuPirce> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<DesingerMain> getStoreDetail(String oid) {
        return api.getStoreDetail("shop.index/store_detail", SpUtil.getInstance().getString(TokenKey.TOKEN), oid)
                .flatMap(new Func1<ResultBean<DesingerMain>, Observable<DesingerMain>>() {
                    @Override
                    public Observable<DesingerMain> call(ResultBean<DesingerMain> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<List<PetConcer>> getPetConcers(String longTitu, String latitude, String page, String search, String provice_id) {
        return api.getPetConcers("user.pet/petcornlist", SpUtil.getInstance().getString(TokenKey.TOKEN), longTitu,latitude,page,search,provice_id)
                .flatMap(new Func1<ResultBean<List<PetConcer>>, Observable<List<PetConcer>>>() {
                    @Override
                    public Observable<List<PetConcer>> call(ResultBean<List<PetConcer>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    /**
     * 币种列表
     *
     * @return
     */
    public Observable<CommList<List<Money>>> getCurrencyList() {
        HashMap<String, String> map = getMap();
        return api.get_currency_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Money>>>, Observable<CommList<List<Money>>>>() {
                    @Override
                    public Observable<CommList<List<Money>>> call(ResultBean<CommList<List<Money>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<User> checkToken() {
        return api.checkToen(SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),"user.index/check_token")
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 删除地址
     *
     * @param aid
     * @return
     */
    public Observable<User> address_del(String aid) {
        return api.address_del("user.address/del_address", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), aid)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 收藏店铺列表
     *
     * @return
     */
    public Observable<CommList<List<CollectShop>>> store_list() {
        HashMap<String, String> map = getMap();
        return api.store_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<CollectShop>>>, Observable<CommList<List<CollectShop>>>>() {
                    @Override
                    public Observable<CommList<List<CollectShop>>> call(ResultBean<CommList<List<CollectShop>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 删除收藏店铺
     *
     * @param aid
     * @return
     */
    public Observable<User> store_del(String aid) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ID, aid);
        return api.store_del(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 商品列表
     *
     * @param
     * @return
     */
    public Observable<List<OrderType>> collect_item_list(String type) {

        return api.collect_item_list("shop.index/fav_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), type)
                .flatMap(new Func1<ResultBean<List<OrderType>>, Observable<List<OrderType>>>() {
                    @Override
                    public Observable<List<OrderType>> call(ResultBean<List<OrderType>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 删除收藏商品
     *
     * @param aid
     * @return
     */
    public Observable<User> collect_item_del(String type, String aid) {
        HashMap<String, String> map = getMap();
        map.put(Constant.COLLECT_ID, aid);
        map.put(Constant.TYPE, type);
        return api.collect_item_del(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), type, map.get(Constant.COLLECT_ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 删除地址
     *
     * @param aid
     * @return
     */
    public Observable<User> add_item_tag(String aid, String tag) {
        HashMap<String, String> map = getMap();
        map.put(Constant.COLLECT_ID, aid);
        map.put(Constant.TYPE, tag);
        return api.add_item_tag(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.COLLECT_ID), map.get(Constant.TYPE), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 优惠券
     *
     * @return
     */
    public Observable<Coupons> checkCouponCode(String tag) {
        HashMap<String, String> map = getMap();
        map.put(Constant.CODE, tag);
        return api.checkCouponCode(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.CODE), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Coupons>, Observable<Coupons>>() {
                    @Override
                    public Observable<Coupons> call(ResultBean<Coupons> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 积分列表
     */
    public Observable<CommList<List<Point>>> getPoints() {
        HashMap<String, String> map = getMap();

        return api.getPointList(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map)).subscribeOn(Schedulers.io())
                .flatMap(new Func1<ResultBean<CommList<List<Point>>>, Observable<CommList<List<Point>>>>() {
                    @Override
                    public Observable<CommList<List<Point>>> call(ResultBean<CommList<List<Point>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 物流详情查询
     */
    public Observable<LogistDetail> getLogistDetail(String pgId, String pgCode) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PG_ID, pgId);
        map.put(Constant.PG_CODE, pgCode);
        return api.wuliu_detail(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.PG_ID), map.get(Constant.PG_CODE), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map)).subscribeOn(Schedulers.io())
                .flatMap(new Func1<ResultBean<LogistDetail>, Observable<LogistDetail>>() {
                    @Override
                    public Observable<LogistDetail> call(ResultBean<LogistDetail> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 首页弹窗
     */
    public Observable<Cate> getFreeZoomsColumn() {
        HashMap<String, String> map = getMap();


        return api.get_featured_data_column(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map)).subscribeOn(Schedulers.io())
                .flatMap(new Func1<ResultBean<Cate>, Observable<Cate>>() {
                    @Override
                    public Observable<Cate> call(ResultBean<Cate> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 广告
     */
    public Observable<CommList<List<VpPacket>>> getVpPackets(
    ) {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.getVpPackets(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<VpPacket>>>, Observable<CommList<List<VpPacket>>>>() {
                    @Override
                    public Observable<CommList<List<VpPacket>>> call(ResultBean<CommList<List<VpPacket>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 首页分类接口
     *
     * @return
     */
    public Observable<List<ZoomList>> get_store_category_list(String cagatry_id, String column_id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.Column_id, column_id);
        map.put(Constant.CATEGROY_ID, cagatry_id);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_store_category_list(map.get(Constant.CURRENCY), map.get(Constant.CATEGROY_ID), map.get(Constant.Column_id), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<ZoomList>>, Observable<List<ZoomList>>>() {
                    @Override
                    public Observable<List<ZoomList>> call(ResultBean<List<ZoomList>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 首页分类接口
     *
     * @return
     */
    public Observable<List<StyleList>> get_store_category_list(String column_id) {
        HashMap<String, String> map = getMap();

        map.put(Constant.Column_id, column_id);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_store_category_list(map.get(Constant.CURRENCY), map.get(Constant.Column_id), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<StyleList>>, Observable<List<StyleList>>>() {
                    @Override
                    public Observable<List<StyleList>> call(ResultBean<List<StyleList>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * type分类
     */
    public Observable<CommList<List<FirstCategroy>>> type_category_list() {
        HashMap<String, String> map = getMap();
        return api.type_category_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<FirstCategroy>>>, Observable<CommList<List<FirstCategroy>>>>() {
                    @Override
                    public Observable<CommList<List<FirstCategroy>>> call(ResultBean<CommList<List<FirstCategroy>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 订单列表状态
     */
    public Observable<List<BigOrder>> order_lists(String status, String page) {

        return api.my_order("order.index/get_service_order_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),status,page,"10")
                .flatMap(new Func1<ResultBean<List<BigOrder>>, Observable<List<BigOrder>>>() {
                    @Override
                    public Observable<List<BigOrder>> call(ResultBean<List<BigOrder>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    /**
     * 订单列表状态
     */
    public Observable<YueDetail> getYueDetail( String page) {

        return api.getYueDetail("user.account/get_my_balance_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),page,"10")
                .flatMap(new Func1<ResultBean<YueDetail>, Observable<YueDetail>>() {
                    @Override
                    public Observable<YueDetail> call(ResultBean<YueDetail> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 订单列表状态
     */
    public Observable<com.ad.pet.models.remote.account.Point> getPointDetail(String page) {

        return api.getPointDetail("user.account/get_my_point_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),page,"10")
                .flatMap(new Func1<ResultBean<com.ad.pet.models.remote.account.Point>, Observable<com.ad.pet.models.remote.account.Point>>() {
                    @Override
                    public Observable<com.ad.pet.models.remote.account.Point> call(ResultBean<com.ad.pet.models.remote.account.Point> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 订单物流列表
     */
    public Observable<BigOrder> order_packet_lists(String order_id) {

        return api.order_packet_lists("order.index/get_service_order_info", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id)
                .flatMap(new Func1<ResultBean<BigOrder>, Observable<BigOrder>>() {
                    @Override
                    public Observable<BigOrder> call(ResultBean<BigOrder> commListResultBean) {
                        return ResultCheck.checkResponse(commListResultBean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 未付款订单列表
     *
     * @return
     */
    public Observable<List<BigOrder>> order_unpaid(String order_status,String page) {

        return api.pending("order.index/get_goods_order_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_status,page,"10")
                .flatMap(new Func1<ResultBean<List<BigOrder>>, Observable<List<BigOrder>>>() {
                    @Override
                    public Observable<List<BigOrder>> call(ResultBean<List<BigOrder>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<List<OrderType>> appoint_list(String status, String page) {

        return api.appoint_list("shop.index/appoint_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),status,page,"10")
                .flatMap(new Func1<ResultBean<List<OrderType>>, Observable<List<OrderType>>>() {
                    @Override
                    public Observable<List<OrderType>> call(ResultBean<List<OrderType>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 取消订单
     *
     * @return
     */
    public Observable<User> cancel_order(String order_id) {

        return api.cancel_order("order.index/cancel", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<BigOrder> getGoodOrderDetail(String order_id) {

        return api.get_good_detail_order("order.index/get_goods_order_info", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id)
                .flatMap(new Func1<ResultBean<BigOrder>, Observable<BigOrder>>() {
                    @Override
                    public Observable<BigOrder> call(ResultBean<BigOrder> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> confir_order(String order_id) {

        return api.confirm_order("order.index/confirm_receipt", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<User> cancel_appoint(String order_id) {

        return api.appoint_cancel("shop.index/appoint_cancel", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<String> addservicefav(String order_id,String shopid) {

        return api.addservicefav("shop.index/addservicefav", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id,shopid)
                .flatMap(new Func1<ResultBean<String>, Observable<String>>() {
                    @Override
                    public Observable<String> call(ResultBean<String> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<String> cancelservicefav(String order_id,String shopid) {

        return api.cancelservicefav("shop.index/cancelservicefav", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN),order_id,shopid)
                .flatMap(new Func1<ResultBean<String>, Observable<String>>() {
                    @Override
                    public Observable<String> call(ResultBean<String> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 包裹订单详情
     *
     * @return
     */
    public Observable<User> return_balance(String pgId, String bsn) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, pgId);
        map.put(Constant.BANLANCE_SIGN, bsn);
        return api.return_balance(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.ORDER_SN), bsn, map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 取消订单
     *
     * @param pgId
     * @return
     */
    public Observable<OrderDetail> package_detail(String pgId) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, pgId);
        return api.package_detail(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.ORDER_SN), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<OrderDetail>, Observable<OrderDetail>>() {
                    @Override
                    public Observable<OrderDetail> call(ResultBean<OrderDetail> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 确认订单接口
     */
    public Observable<ResultBean> confirm_receipt(String order_id, String product_id, String order_product_id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_ID, order_id);
        map.put(Constant.PRODUCT_ID, product_id);
        map.put(Constant.ORDER_PRODUCT_ID, order_product_id);
        return api.confirm_receipt(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.ORDER_ID), map.get(Constant.PRODUCT_ID), map.get(Constant.ORDER_PRODUCT_ID), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 评论内容接口
     */
    public Observable<ResultBean> receiving_comment(String order_id, String product_id, String order_product_id, String rating, String content, String image) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_ID, order_id);
        map.put(Constant.PRODUCT_ID, product_id);
        map.put(Constant.ORDER_PRODUCT_ID, order_product_id);
        map.put(Constant.RATING, rating);
        map.put(Constant.CONTENT, content);
        map.put(Constant.IMAGE, image);
        return api.receiving_comment(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), order_id, product_id, order_product_id, rating, content, image, map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 邮箱注册
     */
    public Observable<User> reset_pwd(String pwd, String new_pwd, String confir_newpwd) {


        return api.reset_password("user.index/edit_passwd", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), pwd, new_pwd
        )
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 邮箱注册
     */
    public Observable<AboutUs> about_us() {


        return api.about_us("common.sms/about_as", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN)
        )
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<AboutUs>, Observable<AboutUs>>() {
                    @Override
                    public Observable<AboutUs> call(ResultBean<AboutUs> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 邮箱注册
     */
    public Observable<User> sendSuggess(String text) {


        return api.suggesst("user.index/feedback", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), text
        )
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }
    public Observable<User> cancellation() {


        return api.cancellation("user.index/cancellation", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }
    /**
     * 获取商品缓存
     */
    public Observable<Product_list> getProductByCategory(String category_id, String page, String sort, String sort_order, String start_price, String end_price) {
        HashMap<String, String> map = getMap();
        map.put(Constant.CATEGROY_ID, category_id);
        map.put(Constant.PAGE, page);
        map.put(Constant.SORT, sort);
        map.put(Constant.SORT_ORDER, sort_order);
        map.put(Constant.START_PRICE, start_price);
        map.put(Constant.END_PRICE, end_price);
        map.put(Constant.LIMIT, "50");

        return api.getProductByCategory(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), category_id, page, sort, sort_order, start_price, end_price
                , map.get(Constant.LIMIT), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<Product_list>, Observable<Product_list>>() {
                    @Override
                    public Observable<Product_list> call(ResultBean<Product_list> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 省市
     */
    public Observable<List<Province>> getProvinceCity() {

        return api.getStateList("user.address/get_region_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<List<Province>>, Observable<List<Province>>>() {
                    @Override
                    public Observable<List<Province>> call(ResultBean<List<Province>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 获取支付方法列表
     */
    public Observable<PayMethodAll> get_method_list(String sn_id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, sn_id);
        return api.get_method_list(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), sn_id, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<PayMethodAll>, Observable<PayMethodAll>>() {
                    @Override
                    public Observable<PayMethodAll> call(ResultBean<PayMethodAll> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 创建支付订单
     */
    public Observable<PayUrl> create_pay(String type, String amount, String pm_id, String order_sn, String uid, String pay_sign) {
        HashMap<String, String> map = getMap();
        map.put(Constant.TYPE, type);
        map.put(Constant.AMOUNT, amount);
        map.put(Constant.PM_ID, pm_id);
        map.put(Constant.ORDER_SN, order_sn);
        map.put(Constant.UID, uid);
        map.put(Constant.PAY_SIGN, pay_sign);
        return api.create_pay(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), type, amount, pm_id, order_sn, uid, pay_sign, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<PayUrl>, Observable<PayUrl>>() {
                    @Override
                    public Observable<PayUrl> call(ResultBean<PayUrl> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 提交支付建议
     */
    public Observable<User> add_comment(String sn_id, String content) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, sn_id);
        map.put(Constant.CONTENT, content);
        return api.add_comment(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), sn_id, content, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 获取完成订单页面
     */
    public Observable<PayCompleted> pay_completed(String sn_id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, sn_id);
        return api.pay_completed(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), sn_id, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<PayCompleted>, Observable<PayCompleted>>() {
                    @Override
                    public Observable<PayCompleted> call(ResultBean<PayCompleted> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 获取订单详情页
     *
     * @param pid
     * @return
     */
    public Observable<ProductDetail> getProductDetial(String pid) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PRODUCT_ID, pid);
        return api.getProductDetial(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), pid, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<ProductDetail>, Observable<ProductDetail>>() {
                    @Override
                    public Observable<ProductDetail> call(ResultBean<ProductDetail> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 获取评论列表
     *
     * @param pid
     * @return
     */
    public Observable<CommList<List<Rating>>> getRatingList(String pid, String page, String size) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PRODUCT_ID, pid);
        map.put(Constant.PAGE, page);
        map.put(Constant.SIZE, size);
        return api.getRatingList(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), pid, page, size, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<CommList<List<Rating>>>, Observable<CommList<List<Rating>>>>() {
                    @Override
                    public Observable<CommList<List<Rating>>> call(ResultBean<CommList<List<Rating>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 获取订单记录
     *
     * @param pid
     * @return
     */
    public Observable<CommList<List<Record>>> getSalesRecords(String pid, String page, String size) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PRODUCT_ID, pid);
        map.put(Constant.PAGE, page);
        map.put(Constant.SIZE, size);
        return api.getTransactionList(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), pid, page, size, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<CommList<List<Record>>>, Observable<CommList<List<Record>>>>() {
                    @Override
                    public Observable<CommList<List<Record>>> call(ResultBean<CommList<List<Record>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    public Observable<SearchEndGood> getSearchEnd(String keyword, String page, String limit, String sort, String sort_order, String start_price, String end_price, String category_id, String attr) {
        HashMap<String, String> map = getMap();
        map.put(Constant.KEY_WORD, keyword);
        map.put(Constant.PAGE, page);
        map.put(Constant.LIMIT, limit);
        map.put(Constant.SORT, sort);
        map.put(Constant.SORT_ORDER, sort_order);
        map.put(Constant.START_PRICE, start_price);
        map.put(Constant.END_PRICE, end_price);
        map.put(Constant.CATEGROY_ID, category_id);
        map.put(Constant.ATTR, attr);
//        map.put(Constant.IS_MAIN,is_home_cate);

        return api.search_product(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), keyword, page, limit, sort, sort_order, start_price, end_price, category_id, attr, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<SearchEndGood>, Observable<SearchEndGood>>() {
                    @Override
                    public Observable<SearchEndGood> call(ResultBean<SearchEndGood> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    public Observable<User> addToCart(String pid, String qunaity, String sku, String storeId) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PRODUCT_ID, pid);
        map.put(Constant.QUANTITY, qunaity);
        map.put(Constant.SKU, sku);
        map.put(Constant.STORE_ID, storeId);
        return api.addToCart(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), pid, qunaity, sku, storeId, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 获取账户信息
     *
     * @return
     */
    public Observable<Banlance> getUserBalance() {
        HashMap<String, String> map = getMap();
        return api.get_user_balance(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<Banlance>, Observable<Banlance>>() {
                    @Override
                    public Observable<Banlance> call(ResultBean<Banlance> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 运输方式
     *
     * @return
     */
    public Observable<BigShipingw> getShippingWays(String quanity, String price) {
        HashMap<String, String> map = getMap();
        map.put(Constant.QUANTITY, quanity);
        map.put(Constant.PRICE, price);
        return api.get_shipping_data(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.QUANTITY), price, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<BigShipingw>, Observable<BigShipingw>>() {
                    @Override
                    public Observable<BigShipingw> call(ResultBean<BigShipingw> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 支付余额校验
     *
     * @return
     */
    public Observable<User> paymentBalance(String order_sn, String balance_sign, String balance, String balance_red_envele) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, order_sn);
        map.put(Constant.BANLANCE_SIGN, balance_sign);
        map.put(Constant.BANLANCE, balance);
        map.put(Constant.RED_ENVELOPS, balance_red_envele);
        return api.payment_balance(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), order_sn, balance_sign, balance, balance_red_envele, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 获取用户余额提现的所有信息
     *
     * @return
     */
    public Observable<WithDraw> getUserWithdrawWindow() {
        HashMap<String, String> map = getMap();
        return api.getUserWithdrawWindow(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<WithDraw>, Observable<WithDraw>>() {
                    @Override
                    public Observable<WithDraw> call(ResultBean<WithDraw> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    /**
     * 发起提现请求
     * 1.0.0
     *
     * @return
     */
    public Observable<User> addWithdrawAmount(String tp, String ano, String aname, String amount) {
        HashMap<String, String> map = getMap();
        map.put(Constant.TYPE, tp);
        map.put(Constant.ACCOUNT_NO, ano);
        map.put(Constant.ACCOUNT_NAME, aname);
        map.put(Constant.WITHDAWN_AMOUNT, amount);
        return api.addUserWithdraw(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), tp, ano, aname, amount, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    public Observable<SignCheck> checkIsSign() {
        HashMap<String, String> map = getMap();
        return api.check_is_sign(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<SignCheck>, Observable<SignCheck>>() {
                    @Override
                    public Observable<SignCheck> call(ResultBean<SignCheck> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    public Observable<SignCheck> DaySign() {
        HashMap<String, String> map = getMap();
        return api.day_sign(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<SignCheck>, Observable<SignCheck>>() {
                    @Override
                    public Observable<SignCheck> call(ResultBean<SignCheck> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    public Observable<SignCheck> pay_completed_open_red_envelope(String orderSn) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_SN, orderSn);
        return api.pay_completed_open_red_envelope(map.get(Constant.LANG), map.get(Constant.CURRENCY), map.get(Constant.COUNTRY), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), orderSn, LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<SignCheck>, Observable<SignCheck>>() {
                    @Override
                    public Observable<SignCheck> call(ResultBean<SignCheck> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    public Observable<BigAdver> getBootAdver(String width, String height) {
        HashMap<String, String> map = getMap();
        map.put(Constant.WIDTH, width);
        map.put(Constant.HEIGHT, height);

//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_boot_page(map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.WIDTH), map.get(Constant.HEIGHT), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<BigAdver>, Observable<BigAdver>>() {
                    @Override
                    public Observable<BigAdver> call(ResultBean<BigAdver> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<SignCheck> app_share_h5_url() {
        HashMap<String, String> map = getMap();
        return api.app_share_h5_url(map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<SignCheck>, Observable<SignCheck>>() {
                    @Override
                    public Observable<SignCheck> call(ResultBean<SignCheck> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }

    public Observable<CountDrawTotal> getCurrentTotalWithdrawal() {
        HashMap<String, String> map = getMap();
        return api.getCurrentTotalWithdrawal(map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Func1<ResultBean<CountDrawTotal>, Observable<CountDrawTotal>>() {
                    @Override
                    public Observable<CountDrawTotal> call(ResultBean<CountDrawTotal> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                });
    }


    /**
     * 获取未读消息数量
     */
    public Observable<User> getReadMessageNumber() {
        HashMap<String, String> map = getMap();
        return api.getUnreadTotal(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 首页消息
     */
    public Observable<List<Message>> message_category_list() {
        HashMap<String, String> map = getMap();
        return api.message_category_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<List<Message>>, Observable<List<Message>>>() {
                    @Override
                    public Observable<List<Message>> call(ResultBean<List<Message>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 各个页面的消息
     */
    public Observable<CommList<List<Message>>> msg_list(String cid) {
        HashMap<String, String> map = getMap();
        map.put(Constant.C_ID, cid);
        return api.msg_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.C_ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Message>>>, Observable<CommList<List<Message>>>>() {
                    @Override
                    public Observable<CommList<List<Message>>> call(ResultBean<CommList<List<Message>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 消息已读
     */
    public Observable<User> messageRead(String id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ID, id);
        return api.isRead(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map)).flatMap(new Func1<ResultBean<User>, Observable<User>>() {
            @Override
            public Observable<User> call(ResultBean<User> bean) {
                return ResultCheck.checkResponse2(bean);
            }
        })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 消息已读
     */
    public Observable<User> messageTypeRead(String id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.C_ID, id);
        return api.isTypeRead(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.C_ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map)).flatMap(new Func1<ResultBean<User>, Observable<User>>() {
            @Override
            public Observable<User> call(ResultBean<User> bean) {
                return ResultCheck.checkResponse2(bean);
            }
        })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    /**
     * 消息删除
     */
    public Observable<User> message_delete_id(String id) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ID, id);
        return api.message_isDel(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<List<DesingerMain>> getDesignerBrandStoreList(String page, String limit, String longitude, String latitude, String keyword, String province_id, String city_id) {

        return api.getDesignerBrandStoreList("shop.index/store_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), page, limit, longitude, latitude, keyword, province_id, city_id)
                .flatMap(new Func1<ResultBean<List<DesingerMain>>, Observable<List<DesingerMain>>>() {
                    @Override
                    public Observable<List<DesingerMain>> call(ResultBean<List<DesingerMain>> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<DesingerType>> getShopService(String shop_id) {

        return api.getShopService("shop.index/offservice_list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), shop_id)
                .flatMap(new Func1<ResultBean<List<DesingerType>>, Observable<List<DesingerType>>>() {
                    @Override
                    public Observable<List<DesingerType>> call(ResultBean<List<DesingerType>> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<User> thirdparty_login(String email, String code, String pwd, String thirdPart, String nickName, String headUrl, String unqionId,String to_reference_code) {

        return api.thirdparty_login("user.index/third_bind_mobile", email, code, pwd, thirdPart, nickName, headUrl, unqionId,JPushInterface.getRegistrationID(App.getApp()).toString(),android,to_reference_code)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })


                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<CommList<List<com.ad.pet.models.remote.message.Record>>> get_transaction_log(String page, String limit) {
        HashMap<String, String> map = getMap();
        map.put(Constant.PAGE, page);
        map.put(Constant.LIMIT, limit);

        return api.get_transaction_log(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), page, limit, LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<com.ad.pet.models.remote.message.Record>>>, Observable<CommList<List<com.ad.pet.models.remote.message.Record>>>>() {
                    @Override
                    public Observable<CommList<List<com.ad.pet.models.remote.message.Record>>> call(ResultBean<CommList<List<com.ad.pet.models.remote.message.Record>>> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<NewUserBenfit> getNewUserBoon() {
        HashMap<String, String> map = getMap();


        return api.getNewUserBoon(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<NewUserBenfit>, Observable<NewUserBenfit>>() {
                    @Override
                    public Observable<NewUserBenfit> call(ResultBean<NewUserBenfit> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<Product_list> new_user_boon_product() {
        HashMap<String, String> map = getMap();
        return api.new_user_boon_product(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<Product_list>, Observable<Product_list>>() {
                    @Override
                    public Observable<Product_list> call(ResultBean<Product_list> bean) {
                        return ResultCheck.checkResponse2(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<CommList<List<Good>>> getProductList() {
        HashMap<String, String> map = getMap();
        return api.get_product_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.ID), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<Good>>>, Observable<CommList<List<Good>>>>() {
                    @Override
                    public Observable<CommList<List<Good>>> call(ResultBean<CommList<List<Good>>> commListResultBean) {
                        return ResultCheck.checkResponse2(commListResultBean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<BigArticle> youlike(String classId, String page) {
        return api.getArticleList("article.index/list", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), page, classId)
                .flatMap(new Func1<ResultBean<BigArticle>, Observable<BigArticle>>() {
                    @Override
                    public Observable<BigArticle> call(ResultBean<BigArticle> bigArticle) {
                        return ResultCheck.checkResponse(bigArticle);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> articleComment(String articleId, String text) {

        return api.articleComment("article.index/articlecomment", articleId, text)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<BigArticle> getCollectArticleList(String page) {

        return api.getCollectArticleList("article.index/memberfav", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), page)
                .flatMap(new Func1<ResultBean<BigArticle>, Observable<BigArticle>>() {
                    @Override
                    public Observable<BigArticle> call(ResultBean<BigArticle> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> collectArticle(String articleId) {

        return api.collectArticle("article.index/addarticlefav", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), articleId)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> cancelCollectArticle(String articleId) {

        return api.articleComment("article.index/cancelarticlefav", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), articleId)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<String> zanArticle(String articleId) {

        return api.zanArticle("article.index/addarticlezan", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), articleId)
                .flatMap(new Func1<ResultBean<String>, Observable<String>>() {
                    @Override
                    public Observable<String> call(ResultBean<String> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<String> cancelZanArticle(String articleId) {

        return api.cancelZanArticle("article.index/cancelarticlezan", SpUtil.getInstance().getString(Constant.ACCESS_TOKEN), articleId)
                .flatMap(new Func1<ResultBean<String>, Observable<String>>() {
                    @Override
                    public Observable<String> call(ResultBean<String> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<CommList<List<MainFloor>>> getHomeFloorData() {
        HashMap<String, String> map = getMap();
        map.put(Constant.IS_NEW_FLOOR, "2.0.0");
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.GetHomeFloorData(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.IS_NEW_FLOOR), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<MainFloor>>>, Observable<CommList<List<MainFloor>>>>() {
                    @Override
                    public Observable<CommList<List<MainFloor>>> call(ResultBean<CommList<List<MainFloor>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<PopNewRegist> register_sign_home() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.register_sign_home(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<PopNewRegist>, Observable<PopNewRegist>>() {
                    @Override
                    public Observable<PopNewRegist> call(ResultBean<PopNewRegist> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<PopNewRegist> check_is_sign_home() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.check_is_sign_home(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<PopNewRegist>, Observable<PopNewRegist>>() {
                    @Override
                    public Observable<PopNewRegist> call(ResultBean<PopNewRegist> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<ShareEndItem> app_share_product_data() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.app_share_product_data(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<ShareEndItem>, Observable<ShareEndItem>>() {
                    @Override
                    public Observable<ShareEndItem> call(ResultBean<ShareEndItem> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<ShareEndItem> app_share_friend_data() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.app_share_friend_data(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<ShareEndItem>, Observable<ShareEndItem>>() {
                    @Override
                    public Observable<ShareEndItem> call(ResultBean<ShareEndItem> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<User> change_order_detail_address(String oid, String firstname, String lastname,
                                                        String address, String country_id, String state_id, String state, String city_id, String city,
                                                        String postcode, String phone) {
        HashMap<String, String> map = getMap();
        map.put(Constant.ORDER_ID, oid);
        map.put(Constant.FIRST_NAME, firstname);
        map.put(Constant.LASTNAME, lastname);
        map.put(Constant.ADDRESS, address);
        map.put(Constant.PHONE, phone);
        map.put(Constant.COUNTRY_ID, country_id);
        map.put(Constant.STATE_ID, state_id);
        map.put(Constant.STATE, state);
        map.put(Constant.CITY_ID, city_id);
        map.put(Constant.CITY, city);
        map.put(Constant.POST_CODE, postcode);
        map.put(Constant.PHONE, phone);


        return api.change_order_detail_address(map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), oid, map.get(Constant.FIRST_NAME), map.get(Constant.LASTNAME), map.get(Constant.ADDRESS),
                map.get(Constant.COUNTRY_ID), map.get(Constant.STATE_ID), map.get(Constant.STATE), map.get(Constant.CITY_ID), map.get(Constant.CITY),
                map.get(Constant.POST_CODE), map.get(Constant.PHONE),
                map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<CommList<List<HomeMall>>> get_track_product_list() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_track_product_list(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<CommList<List<HomeMall>>>, Observable<CommList<List<HomeMall>>>>() {
                    @Override
                    public Observable<CommList<List<HomeMall>>> call(ResultBean<CommList<List<HomeMall>>> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> getUserCartProductNum() {
        HashMap<String, String> map = getMap();
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.getUserCartProductNum(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> updateSelectType(String cartIds) {
        HashMap<String, String> map = getMap();
        map.put(Constant.CART_IDS, cartIds);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.updateSelectType(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), map.get(Constant.CART_IDS), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> phone_register(String phoneNumber, String smsCode, String password,String to_reference_codeBODY) {
        HashMap<String, String> map = getMap();
        map.put(Constant.METHOD, "user.index/register");
        map.put(Constant.USER_TEL, phoneNumber);
        map.put(Constant.SMS_CODE, smsCode);
        map.put(Constant.USER_PASSWORD, password);

//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.phone_register(map.get(Constant.METHOD), phoneNumber, smsCode, password,JPushInterface.getRegistrationID(App.getApp()).toString(),android,to_reference_codeBODY)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> phone_login(String phoneNumber, String password,String registration_id ) {
        HashMap<String, String> map = getMap();
        map.put(Constant.METHOD, "user.index/login");
        map.put(Constant.USER_TEL, phoneNumber);
        map.put(Constant.USER_PASSWORD, password);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.phone_login(map.get(Constant.METHOD), phoneNumber, password,registration_id,android)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<User> get_sms_code(String phoneNumber, String scene, String second, String type) {
        HashMap<String, String> map = getMap();
        map.put(Constant.METHOD, "common.sms/send_mobile_sms");
        map.put(Constant.PHONE_NUM, phoneNumber);
        map.put(Constant.SCENE, scene);
        map.put(Constant.SECOND, second);
        map.put(Constant.TYPE, type);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_sms_code(map.get(Constant.METHOD), phoneNumber, scene, second, type)
                .flatMap(new Func1<ResultBean<User>, Observable<User>>() {
                    @Override
                    public Observable<User> call(ResultBean<User> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<UserBuyReturn> get_user_buy_return() {
        HashMap<String, String> map = getMap();

//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.get_user_buy_return(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<UserBuyReturn>, Observable<UserBuyReturn>>() {
                    @Override
                    public Observable<UserBuyReturn> call(ResultBean<UserBuyReturn> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<NewProduct> newGetCartProduct(String cartids) {
        HashMap<String, String> map = getMap();
        map.put(Constant.CART_IDS, cartids);
//        map.put(TokenKey.TOKEN, SpUtil.getInstance().getString(TokenKey.TOKEN));
        return api.newGetCartProduct(map.get(Constant.CHOSE_COUNTRY), map.get(Constant.CURRENCY), map.get(Constant.LANG), SpUtil.getInstance().getString(TokenKey.TOKEN), map.get(Constant.DEVICE_ID), map.get(Constant.PLATFORM), cartids, LyxUtils.getSign(map))
                .flatMap(new Func1<ResultBean<NewProduct>, Observable<NewProduct>>() {
                    @Override
                    public Observable<NewProduct> call(ResultBean<NewProduct> bean) {
                        return ResultCheck.checkResponse(bean);
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}
